package cn.train.controler;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.train.service.AdminServices;

@WebServlet("/ChangeStateServlet")
public class ChangeStateServlet extends HttpServlet {
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		String uid=req.getParameter("uid");
		String state=req.getParameter("state");
		AdminServices adser=new AdminServices();
		PrintWriter out=resp.getWriter();
		
			int aid=Integer.parseInt(uid);
			int stat=Integer.parseInt(state);
			int m=adser.changeState(aid, stat);				
			if(m>0){
				out.print(1);
			}else{
				out.print(0);
			}		
}

protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	doGet(req, resp);
}
}
